//////////////////////////////////////////////////////////////////////////////
//
//  Created by Philip Mulcahy on 31/01/2012.
//  Copyright (c) 2012 Philip Mulcahy. All rights reserved.
//
//  This file is part of the note-recog library.
//
//  note-recog is free software: you can redistribute it and/or modify
//  it under the terms of version 3 of the GNU Lesser General Public License 
//  as published by the Free Software Foundation.
//
//  note-recog is distributed is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with note-recog.  If not, see <http://www.gnu.org/licenses/>.
//
//////////////////////////////////////////////////////////////////////////////

#ifndef note_recog_Harmonic_h
#define note_recog_Harmonic_h

#include <iostream>
#include "Slice.h"

class Harmonic
{
private:
    const Slice::fft_iterator _begin;
    const Slice::fft_iterator _end;
    const size_t _bin;
    const float _binWidthHz;
    float _binPrecise;
    float _peak;
    float _halfPowerBw;
    float _power;
    
public:
    Harmonic( 
             Slice::fft_iterator begin,
             Slice::fft_iterator end,
             float binWidthHz,
             size_t iBin
             );
    
    size_t bin() const;
    float binPrecise() const;
    float freq() const;
    float peak() const;
    float halfPowerBw() const;
    float power() const;
    float findBin(
                  bool left,
                  float startBin,
                  float startHeight,
                  float targetHeight) const;
};

std::ostream& operator<<(std::ostream&,const Harmonic&);


#endif
